﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Evan.Common
{
    /// <summary>
    /// 系统关键类
    /// 构建后台表单的html
    /// </summary>
    public static class HtmlHelper
    {
        
        /// <summary>
        /// 获取字段类型
        /// </summary>
        /// <returns></returns>
        public static Dictionary<string, string> GetFieldType()
        {
            
            Dictionary<string, string> FieldType = new Dictionary<string, string>();
            FieldType.Add("input", "文本框");
            FieldType.Add("password", "密码框");
            FieldType.Add("password_eye", "密码框可点击查看内容");
            FieldType.Add("textarea", "文本域");
            FieldType.Add("editor", "编辑器Ueditor");
            FieldType.Add("feditor", "编辑器Feditor");
            FieldType.Add("radio", "单选");
            FieldType.Add("checkbox", "多选");
            FieldType.Add("select", "下拉列表");
            FieldType.Add("multipleselect", "下拉多选列表");
            FieldType.Add("fileupload", "文件上传");
            FieldType.Add("imgupload", "图片上传");
            FieldType.Add("multipleimgupload", "多图上传");
            FieldType.Add("time", "时间选择");
            FieldType.Add("time_minute", "时间选择-精度分钟");
            FieldType.Add("switch", "开关");
            FieldType.Add("list", "字段列表");
            return FieldType;
        }

        /// <summary>
        /// 默认值的获取
        /// </summary>
        /// <returns></returns>
        public static string GetDefaultValue(string flag)
        {
            string return_val = "";
            switch (flag)
            {
                case "{DateTime_HHMM}":
                    return_val = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    break;
                case "{DateTime_HHMMSS}":
                    return_val = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    break;
                default:
                    return_val = flag;
                    break;
            }
            return return_val;
        }

        private static StringBuilder Html_Str = new StringBuilder(100000);

        #region 递归获取栏目  私有方法
        /// <summary>
        /// 仅仅查找栏目 有栏目层级限制
        /// </summary>
        /// <param name="Channel">栏目ID列表 , 这里是需要搜索的顶级栏目ID</param>
        /// <param name="Deep">搜索深度<para>从0开始计算 , eg: 设置深度为 2 那就是搜索到包含第三级栏目为止</para></param>
        /// <param name="FindCount">已经搜索的深度</param>
        /// <param name="ChannelResList">反馈的结果</param>
        /// <param name="AllChannelList">所有栏目列表</param>
        /// <param name="HasTopChannel">是否包含顶级栏目</param>
        /// <returns></returns>
        private static List<dynamic> GetFilterChannel(string Channel, int Deep, int FindCount, List<dynamic> ChannelResList, List<dynamic> AllChannelList, bool HasTopChannel = true)
        {
            if (Deep > 0 && FindCount == Deep)
            {
                return ChannelResList;
            }

            if (FindCount == 0 && HasTopChannel)
            {
                //进来第一次 , Channel为顶级栏目ID
                ChannelResList.Add(AllChannelList.Find((dynamic res) => res.Id == Convert.ToInt32(Channel)));
            }

            List<dynamic> _channel = AllChannelList.FindAll(delegate(dynamic res)
            {
                string pid = res.ParentId.ToString();
                return Channel.Split(',').Contains(pid);
            });

            if (_channel.Count == 0)
            {
                //没有数据了
                return ChannelResList;
            }
            else
            {
                //有数据
                FindCount = FindCount + 1;
                Channel = "";
                foreach (var item in _channel)
                {
                    Channel = Channel + item.Id + ",";
                    ChannelResList.Add(item);
                }
                Channel = Channel.Trim(',');
                GetFilterChannel(Channel, Deep, FindCount, ChannelResList, AllChannelList);
            }
            return ChannelResList;
        }

        /// <summary>
        /// 拿到最后的结果
        /// </summary>
        /// <returns></returns>
        public static Dictionary<string, string> GetFilterResult(List<Evan.Model.SysModel.SelectConfigModel> SelectConfigList, Dictionary<string, string> _temp_Dic)
        {            
            //获取所有栏目
            List<dynamic> AllChannel = new Evan.DataBase.DbOperat("Channel").GetList_2(0, "Id,ParentId,Title,PageType,SortId", "States=1", "SortId Asc,Id Asc");
            //栏目筛选的结果
            List<dynamic> FilterChannel = new List<dynamic>();
            //返回的结果
            List<dynamic> ResultList = new List<dynamic>();
            //顶级栏目的model
            dynamic TopChannelModel = new Evan.Model.DynamicModel();
            //取数据的时候的转换
            Dictionary<string, object> _temp_dic_model  = new Dictionary<string,object>();
            string _temp_str = "";
            //开始解析 每一条是一个栏目规则 通常只有一个的情况居多
            foreach (Evan.Model.SysModel.SelectConfigModel item in SelectConfigList)
            {
                //拿到所有栏目列表
                FilterChannel = GetFilterChannel(item.Channel.ToString(), item.Deep, 0, new List<dynamic>(), AllChannel, true);
                //开始进行筛选

                #region 绑定模式
                //1
                if (item.BindMode.ToLower() == "id-in")
                {
                    if (!string.IsNullOrEmpty(item.Content))
                    {
                        foreach (var c in FilterChannel)
                        {
                            _temp_str = c.Id.ToString();
                            if ((item.Content).Split(',').Contains(_temp_str))
                            {
                                //包含设置的in项目
                                ResultList.Add(c);
                            }
                        }
                    }
                }
                //2
                if (item.BindMode.ToLower() == "id-out")
                {
                    if (!string.IsNullOrEmpty(item.Content))
                    {
                        foreach (var c in FilterChannel)
                        {
                            _temp_str = c.Id.ToString();
                            if (!((item.Content).Split(',').Contains(_temp_str)))
                            {
                                //包含设置的out项目
                                FilterChannel.Remove(c);
                            }
                        }
                        ResultList.Clear();
                        ResultList = FilterChannel;
                    }
                }
                //3
                if (item.BindMode.ToLower() == "type-in")
                {
                    if (!string.IsNullOrEmpty(item.Content))
                    {
                        foreach (var c in FilterChannel)
                        {
                             _temp_str = c.PageType.ToString();
                             if ((item.Content).Split(',').Contains(_temp_str))
                             {
                                 //包含设置的in项目
                                 ResultList.Add(c);
                             }
                        }
                    }
                }
                //4
                if (item.BindMode.ToLower() == "type-out")
                {
                    if (!string.IsNullOrEmpty(item.Content))
                    {
                        foreach (var c in FilterChannel)
                        {
                            _temp_str = c.PageType.ToString();
                            if (!((item.Content).Split(',').Contains(_temp_str)))
                            {
                                //包含设置的out项目
                                FilterChannel.Remove(c);
                            }
                        }
                        ResultList.Clear();
                        ResultList = FilterChannel;
                    }
                }
                if (string.IsNullOrEmpty(item.BindMode) || item.BindMode.ToLower() == "all")
                {
                    ResultList.Clear();
                    ResultList = FilterChannel;
                }
                #endregion
                
                if (item.BindType.ToLower() == "channel")
                {
                    //绑定的是栏目  就需要找栏目
                    //栏目不用找 , 直接就可以了
                    foreach (var r in ResultList)
                    {
                        _temp_Dic.Add(r.Id.ToString(), r.Title.ToString());
                    }
                }
                if (item.BindType.ToLower() == "content")
                {
                    //绑定的是内容  就需要找内容
                    //找内容
                    string cid_list = "";
                    string ctable_list = "";
                    foreach (var l in ResultList)
                    {
                        cid_list = cid_list + l.Id.ToString() + ",";
                        #region 拿表名
                        string _temp_ctable_list = Evan.Template.TemplateHelper.GetTableNameByPageType(Convert.ToInt32(l.PageType));
                        if (!ctable_list.Contains(_temp_ctable_list))
                        {
                            ctable_list = ctable_list + Evan.Template.TemplateHelper.GetTableNameByPageType(Convert.ToInt32(l.PageType)) + ",";
                        }
                        #endregion
                    }
                    cid_list = cid_list.Trim(',');
                    ctable_list = ctable_list.Trim(',');

                    //拿到数据先
                    #region 拿对应内容数据 , 如果有多个表 , 取第一张表 , 并且写入日志缓存
                    string tabName = ctable_list.Split(',')[0];
                    if (ctable_list.IndexOf(',') > -1)
                    {
                        //有多张表
                        SystemLog.MemLog.AddExLog2("字段绑定模式规则中包含多张表 , 已经默认取第一张表内容", null, "设置的规则包含多张表 , 默认读取第一张表 , 其余表已经被排除 .");
                    }
                    ResultList.Clear();
                    ResultList = new Evan.DataBase.DbOperat(tabName).GetList("States=1 and ClassId in (" + cid_list + ")");
                    #endregion
      
                    if (string.IsNullOrEmpty(item.SelectField))
                    {
                        //默认读取Id,Title
                        foreach (var r in ResultList)
                        {
                            _temp_Dic.Add(r.Id.ToString(), r.Title.ToString());
                        }
                    }
                    else
                    {
                        string[] _select_filed = item.SelectField.Split(',');
                        if (_select_filed.Length == 2)
                        {
                            foreach (var r in ResultList)
                            {
                                _temp_dic_model = Evan.Model.ConvertModel.ConvertToDictionary(r);
                                _temp_Dic.Add(_temp_dic_model[_select_filed[0]].ToString(), _temp_dic_model[_select_filed[1]].ToString());
                            }
                        }
                        else
                        {
                            //默认读取Id,Title
                            foreach (var r in ResultList)
                            {
                                _temp_Dic.Add(r.Id.ToString(), r.Title.ToString());
                            }
                        }
                    }
                }

            }
            return _temp_Dic;
        }

        /// <summary>
        /// 从上往下找栏目 , 有层级限制
        /// </summary>
        /// <param name="ChannelId">栏目ID , 根据这个栏目ID取数据</param>
        /// <param name="Deep">搜索层级 ,</param>
        /// <param name="FindCount">已经搜索的层级 , 内部自增</param>
        /// <param name="AllChannelList">所有栏目列表</param>
        /// <param name="ChannelListRes">最后的返回结果</param>
        /// <param name="BindModel">绑定模式 , 依据绑定模式来决定读取哪些数据</param>
        /// <param name="ContentStr">内容值设置 , 如果不规定 , 可以留空 留空后 BindMode会自动转为all</param>
        /// <returns></returns>
        //private static List<dynamic> GetChannelList(string ChannelId, int Deep, int FindCount, List<dynamic> AllChannelList, List<dynamic> ChannelListRes,string BindModel,string ContentStr)
        //{
        //    //如果传进来的参数是顶级的会造成重定向 , 所以要排除掉
        //    //if (FindCount == 0)
        //    //{
        //    //    if (!string.IsNullOrEmpty(ContentStr))
        //    //    {
        //    //        if (ContentStr.Split(',').Contains(ChannelId))
        //    //        {
        //    //            SystemLog.MemLog.AddExLog2("内容值设置 ( Content值 ) 不能为设置的顶级ID ( 传入Channel值 ) , 否则会造成无限循环 , 出错ID=" + ChannelId, null, "");
        //    //            throw new Exception("内容值设置 ( Content值 ) 与 设置的顶级ID ( 传入Channel值 ) 一致 , 造成了无限循环 , 出错ID=" + ChannelId);
        //    //        }
        //    //    }
        //    //}

        //    //如果层级到了 或者是 下面没有子级栏目了 , 就返回查找的列表
        //    //先看层级是不是到了 查找层级和设置层级一样的时候就不要查了
        //    if (Deep > 0 && FindCount == Deep)
        //    {
        //        return ChannelListRes;
        //    }

        //    //查看当前栏目下面还有没有其他栏目
        //    List<dynamic> _channel = AllChannelList.FindAll(delegate(dynamic res)
        //    {
        //        string pid = res.ParentId.ToString();
        //        return ChannelId.Split(',').Contains(pid);
        //    });

        //    if (_channel.Count == 0)
        //    {
        //        //没有数据了
        //        return ChannelListRes;
        //    }
        //    else
        //    {
        //        //有数据
        //        FindCount = FindCount + 1;
        //        ChannelId = "";
        //        foreach (var item in _channel)
        //        {
        //            ChannelId = ChannelId + item.Id + ",";
        //            ChannelListRes.Add(item);
        //            //AllChannelList.Remove(item);
        //        }
        //        ChannelId = ChannelId.Trim(',');
        //        GetChannelList(ChannelId, Deep, FindCount, AllChannelList, ChannelListRes, BindModel, ContentStr);
        //    }

        //    //所有层级的数据都已经拿完了.  现在开始筛选数据

        //    //#region 绑定模式
        //    //if (BindModel.ToLower() == "id-in")
        //    //{
        //    //    if (!string.IsNullOrEmpty(ContentStr))
        //    //    {
        //    //        _channel = _channel.FindAll(delegate(dynamic res)
        //    //        {
        //    //            string id_in = res.Id.ToString();
        //    //            return ContentStr.Split(',').Contains(id_in);
        //    //        });
        //    //    }
        //    //}
        //    //if (BindModel.ToLower() == "id-out")
        //    //{
        //    //    if (!string.IsNullOrEmpty(ContentStr))
        //    //    {
        //    //        _channel = _channel.FindAll(delegate(dynamic res)
        //    //        {
        //    //            string id_out = res.Id.ToString();
        //    //            return !ContentStr.Split(',').Contains(id_out);
        //    //        });
        //    //    }
        //    //}
        //    //if (BindModel.ToLower() == "type-in")
        //    //{
        //    //    if (!string.IsNullOrEmpty(ContentStr))
        //    //    {
        //    //        _channel = _channel.FindAll(delegate(dynamic res)
        //    //        {
        //    //            string type_in = res.PageType.ToString();
        //    //            return ContentStr.Split(',').Contains(type_in);
        //    //        });
        //    //    }
        //    //}
        //    //if (BindModel.ToLower() == "type-out")
        //    //{
        //    //    if (!string.IsNullOrEmpty(ContentStr))
        //    //    {
        //    //        _channel = _channel.FindAll(delegate(dynamic res)
        //    //        {
        //    //            string type_out = res.PageType.ToString();
        //    //            return ContentStr.Split(',').Contains(type_out) == false;
        //    //        });
        //    //    }
        //    //}
        //    //#endregion

        //    return ChannelListRes;
        //}

        //public static List<dynamic> test(string t,int topid,string ids)
        //{
        //    List<dynamic> AllChannel = new Evan.DataBase.DbOperat("Channel").GetList_2(0, "Id,ParentId,Title,PageType,SortId", "States=1", "SortId Asc,Id Asc");
        //    dynamic TopChannelModel = AllChannel.Find((dynamic res) => res.Id == topid);
        //    List<dynamic> a = new List<dynamic> ();
        //    a.Add(TopChannelModel);
        //    return GetChannelList(TopChannelModel.Id.ToString(), 0, 0, AllChannel, a, t, ids);
        //}
        #endregion

        /// <summary>
        /// 将dynamic转换为HtmlModel 用于后台页面渲染
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public static Model.SysModel.HtmlHelperModel ConvertToHtmlHelperModel(dynamic Model)
        {
            Evan.Model.SysModel.HtmlHelperModel HtmlHelperModel = new Model.SysModel.HtmlHelperModel();
            if (Model != null)
            {
                HtmlHelperModel.Title = Model.Title;
                HtmlHelperModel.FieldName = Model.FieldName;
                HtmlHelperModel.FieldVerify = Model.FieldVerify;
                HtmlHelperModel.PlaceHoder = Model.PlaceHoder;
                HtmlHelperModel.Notice = Model.Notice;
                HtmlHelperModel.MaxLength = Model.MaxLength;

                if (!string.IsNullOrEmpty(Model.DefaultValue))
                {
                    HtmlHelperModel.DefaultValue = Model.DefaultValue;
                }
                else
                {
                    HtmlHelperModel.DefaultValue = "";
                }


                HtmlHelperModel.Hide = Model.IsShow == 0 ? true : false;
                HtmlHelperModel.FieldType = Model.FieldType;


                if (HtmlHelperModel.FieldType.ToLower() == "list")
                {
                    Dictionary<string, string> _temp_Dic = new Dictionary<string, string>();
                    _temp_Dic.Add("field", Model.Content);
                    HtmlHelperModel.SelectItem = _temp_Dic;
                    if (string.IsNullOrEmpty(Model.DefaultValue)) { HtmlHelperModel.DefaultValue = "[]"; }
                }
                else
                {
                    if (!string.IsNullOrEmpty(Model.Content))
                    {
                        string Content = Model.Content;
                        Content = Content.Trim().Trim('\n');
                        Dictionary<string, string> _temp_Dic = new Dictionary<string, string>();

                        //bind开头绑定数据
                        if (Model.Content.Trim().StartsWith("bind-"))
                        {
                            string[] role = Model.Content.Split('-');
                            //SystemLog.MemLog.AddExLog2("使用 bind- 绑定数据", null, Model.Content);
                            //如果是数字  就拿栏目绑定
                            string TableName = role[1];
                            //SystemLog.MemLog.AddExLog2("使用 bind- 绑定数据 拿到表", null, TableName);
                            string thisclassid = role[2];
                            //SystemLog.MemLog.AddExLog2("使用 bind- 绑定数据 拿到ClassId", null, thisclassid);
                            string thiswhere = "States=1";
                            if (thisclassid.Contains(","))
                            {
                                thiswhere += " and ClassId in (" + thisclassid + ")";
                                //SystemLog.MemLog.AddExLog2("使用 bind- 绑定数据 多个栏目绑定 Id List", null, thisclassid);
                            }
                            else if (thisclassid.Contains("select"))
                            {
                                thiswhere += " and ClassId in " + thisclassid;
                            }
                            else
                            {
                                if (Convert.ToInt32(thisclassid) > 0)
                                {
                                    thiswhere += " and ClassId=" + thisclassid;
                                    //SystemLog.MemLog.AddExLog2("使用 bind- 绑定数据 单栏目绑定 Id ", null, thisclassid);
                                }
                            }

                            List<dynamic> DataList = new Evan.DataBase.DbOperat(TableName).GetList_2(0, "Id,Title", thiswhere, "ClassId desc, Id desc");
                            //SystemLog.MemLog.AddExLog2("加载数据类", null, "表-" + TableName + " , " + Model.Content + " , " + DataList.Count);
                            if (DataList.Count > 0)
                            {
                                //Dictionary<string, string> _temp_Dic = new Dictionary<string, string>();
                                foreach (var item in DataList)
                                {
                                    _temp_Dic.Add(item.Id.ToString(), item.Title.ToString());
                                }
                                HtmlHelperModel.SelectItem = _temp_Dic;
                            }
                            else
                            {
                                HtmlHelperModel.SelectItem = new Dictionary<string, string>();
                            }
                        }
                        //JSON数据
                        else if (Content.StartsWith("[") && Content.EndsWith("]"))
                        {
                            try
                            {
                                //说明是以JSON数组进来的
                                Content = Content.Replace("\n", ""); //去掉所有的回车符号
                                List<Evan.Model.SysModel.SelectConfigModel> SelectConfigList = Evan.Common.JsonHelper.JsonToList<Evan.Model.SysModel.SelectConfigModel>(Content); //拿到列表

                                if (SelectConfigList.Count == 0)
                                {
                                    HtmlHelperModel.SelectItem = _temp_Dic;
                                }
                                else
                                {
                                    //拿到数据
                                    HtmlHelperModel.SelectItem = GetFilterResult(SelectConfigList, _temp_Dic);
                                }
                            }
                            catch (Exception ex)
                            {
                                SystemLog.MemLog.AddExLog2("字段绑定内容解析出错", null, ex.ToString());
                                throw new Exception("字段绑定内容解析出错 , 请导出调试日志查看错误详情");
                            }
                        }
                        //ID数据
                        else if (RegexHelper.IsInteger(Model.Content))
                        {
                            //如果是数字  就拿栏目绑定
                            dynamic c = new Evan.DataBase.DbOperat("Channel").GetModel(Convert.ToInt32(Model.Content));
                            string TableName = Evan.Template.TemplateHelper.GetTableNameByPageType(c.PageType);
                            List<dynamic> DataList = new Evan.DataBase.DbOperat(TableName).GetList("States=1 and ClassId=" + Convert.ToInt32(Model.Content));
                            SystemLog.MemLog.AddExLog2("加载数据类", null, "表-" + TableName + " , " + Model.Content + " , " + DataList.Count);
                            if (DataList.Count > 0)
                            {
                                _temp_Dic = new Dictionary<string, string>();
                                foreach (var item in DataList)
                                {
                                    _temp_Dic.Add(item.Id.ToString(), item.Title.ToString());
                                }
                                HtmlHelperModel.SelectItem = _temp_Dic;
                            }
                            else
                            {
                                HtmlHelperModel.SelectItem = new Dictionary<string, string>();
                            }
                        }
                        //正常的绑定数据
                        else
                        {
                            if (Content.Contains("\n"))
                            {
                                string[] arr = Content.Replace("\n", "|").Split('|');
                                for (int i = 0; i < arr.Length; i++)
                                {
                                    _temp_Dic.Add(arr[i].Split(',')[0], arr[i].Split(',')[1]);
                                }
                            }
                            else
                            {
                                if (Content.Contains(","))
                                {
                                    _temp_Dic.Add(Content.Split(',')[0], Content.Split(',')[1]);
                                }
                            }
                            if (_temp_Dic.Count > 0)
                            {
                                HtmlHelperModel.SelectItem = _temp_Dic;
                            }
                            else
                            {
                                HtmlHelperModel.SelectItem = new Dictionary<string, string>();
                            }
                        }
                    }
                    else
                    {
                        HtmlHelperModel.SelectItem = new Dictionary<string, string>();
                    }
                }

                return HtmlHelperModel;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 设置必填字段红色的星号
        /// </summary>
        /// <param name="fieldVerify">notnull 为必填项</param>
        /// <returns></returns>
        public static string requiredFlag(string fieldVerify)
        {
            if (string.IsNullOrEmpty(fieldVerify))
            {
                return "";
            }
            if (fieldVerify.Contains("notnull"))
            {
                return "<span class=\"required\" aria-required=\"true\"> * </span>";
            }
            return "";
        }

        // 验证   " + (string.IsNullOrEmpty(model.FieldVerify) ? "" : "verify=\"" + model.FieldVerify + "\"") + "
        // 最大输入class   " + (model.MaxLength == 0 ? "" : "maxlength_defaultconfig") + "
        // 最大输入属性  " + (model.MaxLength == 0 ? "" : "maxlength=\"" + model.MaxLength + "\"") + "
        // 字段 " + "  field=\"" + model.FieldName + "\"  " + "

        /// <summary>
        /// HTML组件输出
        /// 文本框 input  
        /// 密码框 password ,
        /// 密码框可点击查看内容 password_eye, 
        /// 文本域 textarea , 
        /// 编辑器 editor , 
        /// 单选 radio, 
        /// 多选 checkbox , 
        /// 下拉列表 select , 
        /// 下拉多选列表 multipleselect , 
        /// 文件上传 fileupload , 
        /// 图片上传 imgupload , 
        /// 多图上传 multipleimgupload , 
        /// 时间选择器 time
        /// 时间选择器(分钟) time_minute
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static string HtmlBuild(Model.SysModel.HtmlHelperModel model)
        {
            // 文本框 input , 密码框 password ,密码框可点击查看内容 password_eye , 文本域 textarea , 编辑器 editor , 单选 radio, 多选 checkbox , 下拉列表 select , 下拉多选列表 multipleselect , 文件上传 fileupload , 图片上传 imgupload , 多图上传 multipleimgupload , 
            string html = "";
            switch (model.FieldType)
            {
                case "input":
                    html = Input(model);
                    break;
                case "password":
                    html = Password(model);
                    break;
                case "password_eye":
                    html = Password_Eye(model);
                    break;
                case "textarea":
                    html = Texteara(model);
                    break;
                case "editor":
                    html = Editor(model);
                    break;
                case "radio":
                    html = Radio(model);
                    break;
                case "checkbox":
                    html = CheckBox(model);
                    break;
                case "select":
                    html = Select(model);
                    break;
                case "multipleselect":
                    html = Multipleselect(model);
                    break;
                case "fileupload":
                    html = Fileupload(model);
                    break;
                case "imgupload":
                    html = Imgupload(model);
                    break;
                case "multipleimgupload":
                    html = Multipleimgupload(model);
                    break;
                case "time":
                    html = Time(model);
                    break;
                case "switch":
                    html = Switch(model);
                    break;
                case "feditor":
                    html = FEditor(model);
                    break;
                case "time_minute":
                    html = TimeMinute(model);
                    break;
                case "list":
                    html = FieldList(model);
                    break;
                default:
                    html = "";
                    break;
            }
            return html;
        }

        /// <summary>
        /// 常规输入框
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Input(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + ">");
            Html_Str.Append("     <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("     <div class=\"col-md-6\">");
            Html_Str.Append("         <input type=\"text\" class=\"form-control " + (model.MaxLength == 0 ? "" : "maxlength_defaultconfig") + "\"  " + (model.MaxLength == 0 ? "" : "maxlength=\"" + model.MaxLength + "\"") + "  field=\"" + model.FieldName + "\"  " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + " placeholder=\"" + model.PlaceHoder + "\" field_type=\"" + model.FieldType + "\" value=\"" + model.DefaultValue + "\">");
            Html_Str.Append("         <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("     </div>");
            Html_Str.Append(" </div>");
            return Html_Str.ToString();
        }
        /// <summary>
        /// 密码框 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Password(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            Html_Str.Append("        <input type=\"password\" class=\"form-control\" field=\"" + model.FieldName + "\" " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + " placeholder=\"" + model.PlaceHoder + "\" field_type=\"" + model.FieldType + "\" value=\"" + model.DefaultValue + "\">");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }

        private static string Password_Eye(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            
            Html_Str.Append("           <div class=\"input-group \">");
            Html_Str.Append("                   <input type=\"password\" class=\"form-control\" field=\"" + model.FieldName + "\" " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + " placeholder=\"" + model.PlaceHoder + "\" field_type=\"" + model.FieldType + "\" value=\"" + model.DefaultValue + "\">");
            Html_Str.Append("               <span class=\"input-group-btn\">");
            Html_Str.Append("                   <button class=\"btn green password_eye\" eye=\"" + model.FieldName + "\" type=\"button\"><i class=\"fa fa-eye\"></i></button>");
            Html_Str.Append("               </span>");
            Html_Str.Append("           </div>");

            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }

        
        /// <summary>
        /// 文本域
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Texteara(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            Html_Str.Append("        <textarea class=\"form-control " + (model.MaxLength == 0 ? "" : "maxlength_defaultconfig") + " \" " + "  field=\"" + model.FieldName + "\"  " + "  rows=\"5\" " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + " " + (model.MaxLength == 0 ? "" : "maxlength=\"" + model.MaxLength + "\"") + "  placeholder=\"" + model.PlaceHoder + "\" field_type=\"" + model.FieldType + "\" value=\"" + model.DefaultValue + "\"></textarea>");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }
        /// <summary>
        /// 编辑器
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Editor(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-9  col-sm-9\">");
            //Html_Str.Append("        <script type=\"text/plain\"  id=\"editor_" + model.FieldName + "\"  field=\"" + model.FieldName + "\"  " + " style=\"width:100%;height:500px;\" name=\"editor\"  field_type=\"" + model.FieldType + "\"></script>");
            Html_Str.Append("        <textarea  id=\"editor_" + model.FieldName + "\"  field=\"" + model.FieldName + "\"  " + " style=\"width:100%;height:500px;\" name=\"editor\"  field_type=\"" + model.FieldType + "\">" + model.DefaultValue + "</textarea>");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }
        /// <summary>
        /// 单选按钮
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Radio(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();

            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            Html_Str.Append("        <div class=\"mt-radio-inline\" " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + "  field=\"" + model.FieldName + "\" type=\"radio\" field_type=\"" + model.FieldType + "\" >");

            string[] select_item = model.DefaultValue.Split(',');
            //"+(select_item.Contains(item.Key)? "checked= 'checked'":"") +"
            foreach (var item in model.SelectItem)
            {
                Html_Str.Append("            <label class=\"mt-radio mt-radio-outline\">");
                Html_Str.Append("                <input type=\"radio\" " + (select_item.Contains(item.Key) ? "checked='checked'" : "") + " name=\"options_" + model.FieldName + "\" value=\"" + item.Key + "\" > " + item.Value + "");
                Html_Str.Append("                <span></span>");
                Html_Str.Append("            </label>");
            }

            Html_Str.Append("        </div>");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }
        /// <summary>
        /// 多选按钮
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string CheckBox(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();

            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            Html_Str.Append("        <div class=\"mt-checkbox-inline\" " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + "  field=\"" + model.FieldName + "\" type=\"checkbox\" field_type=\"" + model.FieldType + "\">");

            string[] select_item = model.DefaultValue.Split(',');
            //"+(select_item.Contains(item.Key)? "checked= 'checked'":"") +"

            foreach (var item in model.SelectItem)
            {
                Html_Str.Append("        <label class=\"mt-checkbox mt-checkbox-outline\">");
                Html_Str.Append("            <input type=\"checkbox\" " + (select_item.Contains(item.Key) ? "checked= 'checked'" : "") + " name=\"options_" + model.FieldName + "\"  value=\"" + item.Key + "\"> " + item.Value + "");
                Html_Str.Append("            <span></span>");
                Html_Str.Append("        </label>");
            }

            Html_Str.Append("    </div>");
            Html_Str.Append("    <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }
        /// <summary>
        /// 下拉单选
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Select(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            Html_Str.Append("        <div class=\"select2-bootstrap-prepend\">");
            Html_Str.Append("            <select id=\"single-prepend-text-" + model.FieldName + "\" class=\"form-control select2 select2-allow-clear\" " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + " field=\"" + model.FieldName + "\" field_type=\"" + model.FieldType + "\">");
            Html_Str.Append("                <option></option>");

            string[] select_item = model.DefaultValue.Split(',');
            //"+(select_item.Contains(item.Key)? "checked= 'checked'":"") +"

            foreach (var item in model.SelectItem)
            {
                //if (item.Key == model.DefaultValue)
                if(select_item.Contains(item.Key))
                {
                    Html_Str.Append("                <option value=\"" + item.Key + "\" selected=\"selected\">" + item.Value + "</option>");
                }
                else
                {
                    Html_Str.Append("                <option value=\"" + item.Key + "\" >" + item.Value + "</option>");
                }
            }

            Html_Str.Append("            </select>");
            Html_Str.Append("        </div>");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }
        /// <summary>
        /// 下拉多选
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Multipleselect(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();

            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            Html_Str.Append("        <div class=\"select2-bootstrap-prepend\">");
            Html_Str.Append("            <select id=\"multiple-prepend-text\" class=\"form-control select2\" multiple " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + " field=\"" + model.FieldName + "\" field_type=\"" + model.FieldType + "\">");
            Html_Str.Append("                <option></option>");

            string[] select_item = model.DefaultValue.Split(',');
            //"+(select_item.Contains(item.Key)? "checked= 'checked'":"") +"

            foreach (var item in model.SelectItem)
            {
                if (select_item.Contains(item.Key))
                {
                    Html_Str.Append("                <option value=\"" + item.Key + "\" selected=\"selected\">" + item.Value + "</option>");
                }
                else
                {
                    Html_Str.Append("                <option value=\"" + item.Key + "\" >" + item.Value + "</option>");
                }
                //Html_Str.Append("                <option value=\"" + item.Key + "\" >" + item.Value + "</option>");
            }

            Html_Str.Append("            </select>");
            Html_Str.Append("        </div>");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }
        /// <summary>
        /// 文件上传
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Fileupload(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            //Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \">");
            //Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + "</label>");
            //Html_Str.Append("    <div class=\"col-md-6\">");
            //Html_Str.Append("        <div class=\"fileinput fileinput-new\" data-provides=\"fileinput\">");
            //Html_Str.Append("            <div class=\"input-group input-large\">");
            //Html_Str.Append("                <div class=\"form-control uneditable-input input-fixed input-larg\" data-trigger=\"fileinput\">");
            //Html_Str.Append("                    <i class=\"fa fa-file fileinput-exists\"></i>&nbsp;");
            //Html_Str.Append("                    <span class=\"fileinput-filename\"> </span>");
            //Html_Str.Append("                </div>");
            //Html_Str.Append("                <span class=\"input-group-addon btn default btn-file\">");
            //Html_Str.Append("                    <span class=\"fileinput-new\"> 选择文件 </span>");
            //Html_Str.Append("                    <span class=\"fileinput-exists\"> 重新选择 </span>");
            //Html_Str.Append("                    <input type=\"file\" class=\"" + model.FieldName + "\"  name=\"fileinput_" + model.FieldName + "\"  " + "  field=\"" + model.FieldName + "\"  " + " field_type=\"" + model.FieldType + "\"> </span>");
            //Html_Str.Append("                <a href=\"javascript:;\" class=\"input-group-addon btn red fileinput-exists\" data-dismiss=\"fileinput\"> 移除 </a>");
            //Html_Str.Append("                <a href=\"javascript:;\" class=\"input-group-addon btn File-Upload-Tip File-Upload-Tip-" + model.FieldName + "\">  </a>");
            //Html_Str.Append("            </div>");
            //Html_Str.Append("        </div>");
            //Html_Str.Append("        <span class=\"help-block\">"+model.Notice+"</span>");
            //Html_Str.Append("    </div>");
            //Html_Str.Append("</div>");

            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            Html_Str.Append("        <div class=\"input-group input-icon left\">");
            Html_Str.Append("            <input name=\"filesrc_" + model.FieldName + "\" placeholder=\"" + model.PlaceHoder + "\"  class=\"input-error form-control filesrc\" type=\"text\" value=\"\" /><i class=\"fa fa-file\" style=\"color:#555;font-size:14px;\"></i>");
            Html_Str.Append("            <span class=\"input-group-addon btn default btn-file\">");
            Html_Str.Append("                <span class=\"fileinput-new\"> 选择文件 </span>");
            Html_Str.Append("                <input type=\"file\" class=\"" + model.FieldName + "\" name=\"fileinput_" + model.FieldName + "\"  " + "  field=\"" + model.FieldName + "\"  " + " field_type=\"" + model.FieldType + "\" />");
            Html_Str.Append("            </span> ");
            Html_Str.Append("            <a class=\"input-group-addon btn red fileupload-clear\" name=\"fileclear_" + model.FieldName + "\">移除</a> ");
            Html_Str.Append("            <a href=\"javascript:;\" class=\"input-group-addon btn File-Upload-Tip File-Upload-Tip-" + model.FieldName + "\">  </a>");
            Html_Str.Append("        </div>");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");

            return Html_Str.ToString();
        }
        /// <summary>
        /// 图片上传
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Imgupload(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            Html_Str.Append("        <div class=\"fileinput fileinput-new\" data-provides=\"fileinput\" style=\"width: 100%;\">");
            Html_Str.Append("            <div class=\"fileinput fileinput-new\" data-provides=\"fileinput\" style=\"width: 100%;\">");
            Html_Str.Append("                <div class=\"fileinput-new thumbnail\" style=\"width: 200px; height: 150px; background-color: #EEEEEE;\">");
            Html_Str.Append("                    <img src=\"\" /> ");
            Html_Str.Append("                </div>");
            Html_Str.Append("                <div class=\"fileinput-preview fileinput-exists thumbnail\" style=\"max-width: 200px; height: auto; \"> </div>");
            Html_Str.Append("                <div style=\"margin-bottom:5px\"> <input name=\"imgsrc_" + model.FieldName + "\" type=\"text\" style=\"padding: 6px 12px;\" class=\"form-control imgsrc\" placeholder=\"" + model.PlaceHoder + "\"> </div>");
            Html_Str.Append("                <div>");
            Html_Str.Append("                    <span class=\"btn default btn-file\">");
            Html_Str.Append("                        <span class=\"fileinput-new\"> 选择图片 </span>");
            Html_Str.Append("                        <span class=\"fileinput-exists\"> 更改 </span>");
            Html_Str.Append("                    <input type=\"file\" class=\"" + model.FieldName + "\"  name=\"fileinput_" + model.FieldName + "\"  " + "  field=\"" + model.FieldName + "\"  " + " field_type=\"" + model.FieldType + "\"> </span>");
            Html_Str.Append("                    <a href=\"javascript:;\" class=\"btn red imgupload-clear\" name=\"imgclear_" + model.FieldName + "\"> 移除 </a>");
            Html_Str.Append("                    <a href=\"javascript:;\" class=\"btn Image-Upload-Tip Image-Upload-Tip-" + model.FieldName + "\">  </a>");
            Html_Str.Append("                </div>");
            Html_Str.Append("            </div>");
            Html_Str.Append("        </div>");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }

        /// <summary>
        /// 多图上传
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Multipleimgupload(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("     <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");

            Html_Str.Append("     <div class=\"col-md-8\">");

            Html_Str.Append("           <div class=\"Multiple_" + model.FieldName + "\" field=\"" + model.FieldName + "\" field_type=\"" + model.FieldType + "\" >");

            Html_Str.Append("           </div>");

            Html_Str.Append("           <div class=\"clear\"></div>");


            Html_Str.Append("           <div class=\"fileinput fileinput-new\" data-provides=\"fileinput\">");
            Html_Str.Append("               <span class=\"btn green btn-file\">");
            Html_Str.Append("                   <span class=\"fileinput-new\"> 上传图片 </span>");
            Html_Str.Append("                   <span class=\"fileinput-exists\"> 上传图片 </span>");
            Html_Str.Append("                   <input type=\"file\" rel=\"Multiple-Img-Upload\" class=\"" + model.FieldName + "\" name=\"" + model.FieldName + "\" multiple=\"multiple\"> </span>");
            Html_Str.Append("           </div>");


            Html_Str.Append("         <span class=\"help-block\">" + model.Notice + "</span>");

            Html_Str.Append("         <div class=\"Multiple-UploadTips-" + model.FieldName + " col-md-8\" style=\"display: none; padding:0;\">");
            Html_Str.Append("             <ul style=\"margin:0;padding:0; list-style:none;\">");
            Html_Str.Append("                 <li class=\"Multiple-UploadTips-Process\" style=\"background-color:#eef1f5;margin: 12px 0px 0;background-color: #eef1f5; list-style:none; padding:15px 15px 30px;\">");
            Html_Str.Append("                     <div class=\"display\" style=\"margin-bottom:10px\">");
            Html_Str.Append("                         <div class=\"number\"><small></small></div>");
            Html_Str.Append("                     </div>");
            Html_Str.Append("                     <div class=\"progress-info\">");
            Html_Str.Append("                         <div class=\"progress\"><span style=\"width: 100%;\" class=\"progress-bar progress-bar-success green-sharp\"></span></div>");
            Html_Str.Append("                         <div class=\"status\">");
            Html_Str.Append("                             <div class=\"status-title\">1/1</div>");
            Html_Str.Append("                             <div class=\"status-number\">100%</div>");
            Html_Str.Append("                         </div>");
            Html_Str.Append("                     </div>");
            Html_Str.Append("                 </li>");
            Html_Str.Append("             </ul>");
            Html_Str.Append("         </div>");

            Html_Str.Append("     </div>");


            Html_Str.Append("     <div id=\"multiple-upload-context-menu-" + model.FieldName + "\">");
            Html_Str.Append("         <ul class=\"dropdown-menu\" role=\"menu\">");
            Html_Str.Append("             <li class=\"cm-item\" data-action=\"edit\"><a href=\"javascript:;\"><i class=\"fa fa-edit\"></i> 编辑信息 </a></li>");
            Html_Str.Append("             <li class=\"cm-item\" data-action=\"delete\"><a href=\"javascript:;\"><i class=\"fa fa-remove\"></i> 删除 </a></li>");
            Html_Str.Append("         </ul>");
            Html_Str.Append("     </div>");

            Html_Str.Append("     <div id=\"multiple-upload-dialog-" + model.FieldName + "\" class=\"bootbox modal fade\" tabindex=\"-1\" role=\"dialog\" style=\"display: none; padding-right: 10px;\">");
            Html_Str.Append("         <div class=\"modal-dialog\">");
            Html_Str.Append("             <div class=\"modal-content\">");
            Html_Str.Append("                 <div class=\"modal-header\">");
            Html_Str.Append("                     <button type=\"button\" class=\"bootbox-close-button close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>");
            Html_Str.Append("                     <h4 class=\"modal-title\">编辑第 x 张图片信息</h4>");
            Html_Str.Append("                 </div>");
            Html_Str.Append("                 <div class=\"modal-body\">");
            Html_Str.Append("                     <div class=\"bootbox-body\">");
            Html_Str.Append("                         <div class=\"form\">");
            Html_Str.Append("                             <div class=\"form-horizontal form-row-seperated\">");
            Html_Str.Append("                                 <div class=\"form-group\" style=\"padding-top: 0;\">");
            Html_Str.Append("                                     <label class=\"control-label col-md-2\">输入标题</label>");
            Html_Str.Append("                                     <div class=\"col-md-8\">");
            Html_Str.Append("                                         <input type=\"text\" class=\"form-control multiple-img-title-" + model.FieldName + "\" placeholder=\"请输入图片主题\">");
            Html_Str.Append("                                     </div>");
            Html_Str.Append("                                 </div>");
            Html_Str.Append("                                 <div class=\"form-group\" style=\"border-bottom: none; padding-bottom: 0;\">");
            Html_Str.Append("                                     <label class=\"control-label col-md-2\">输入描述</label>");
            Html_Str.Append("                                     <div class=\"col-md-8\">");
            Html_Str.Append("                                         <textarea class=\"form-control multiple-img-desc-" + model.FieldName + "\" placeholder=\"请输入图片描述\"></textarea>");
            Html_Str.Append("                                     </div>");
            Html_Str.Append("                                 </div>");
            Html_Str.Append("                             </div>");
            Html_Str.Append("                         </div>");
            Html_Str.Append("                     </div>");
            Html_Str.Append("                 </div>");
            Html_Str.Append("                 <div class=\"modal-footer\">");
            Html_Str.Append("                     <button data-bb-handler=\"confirm\" type=\"button\" class=\"btn green\">确定</button>");
            Html_Str.Append("                     <button data-bb-handler=\"cancel\" type=\"button\" class=\"btn default\">取消</button></div>");
            Html_Str.Append("             </div>");
            Html_Str.Append("         </div>");
            Html_Str.Append("     </div>");


            Html_Str.Append(" </div>");



            return Html_Str.ToString();
        }

        /// <summary>
        /// 时间选择器 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Time(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("     <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("     <div class=\"col-md-6\">");
            //Html_Str.Append("         <input type=\"text\" class=\"form-control " + (model.MaxLength == 0 ? "" : "maxlength_defaultconfig") + "\"  " + (model.MaxLength == 0 ? "" : "maxlength=\"" + model.MaxLength + "\"") + "  field=\"" + model.FieldName + "\"  " + (string.IsNullOrEmpty(model.FieldVerify) ? "" : "verify=\"" + model.FieldVerify + "\"") + " placeholder=\"" + model.PlaceHoder + "\"  onclick=\"laydate({istime: true})\" field_type=\"" + model.FieldType + "\">");
            Html_Str.Append("         <input type=\"text\" class=\"form-control date-picker" + "\"  +  field=\"" + model.FieldName + "\"  " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + " placeholder=\"" + model.PlaceHoder + "\"  field_type=\"" + model.FieldType + "\" readonly>");
            //input-medium 
            Html_Str.Append("         <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("     </div>");
            Html_Str.Append(" </div>");
            return Html_Str.ToString();
        }

        /// <summary>
        /// 时间选择器 , 精确到分钟
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string TimeMinute(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("     <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("     <div class=\"col-md-6\">");

            Html_Str.Append("         <div class=\"input-icon\">");
            Html_Str.Append("             <i class=\"fa fa-calendar\"></i>");
            Html_Str.Append("             <input type =\"text\" class=\"form-control date-picker-minute\" maxlength=\"100\" field=\"" + model.FieldName + "\" " + (string.IsNullOrEmpty(model.FieldVerify.Trim(',')) ? "" : "verify=\"" + model.FieldVerify.Trim(',') + "\"") + " placeholder=\"" + model.PlaceHoder + "\"  field_type=\"" + model.FieldType + "\" readonly  value=\"" + GetDefaultValue(model.DefaultValue) + "\">");
            Html_Str.Append("         </div>");
            
            Html_Str.Append("         <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("     </div>");
            Html_Str.Append(" </div>");
            return Html_Str.ToString();
        }


        /// <summary>
        /// 开关 PlaceHoder 为开关里面显示的字
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string Switch(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("     <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-6\">");
            Html_Str.Append("        <input  type=\"checkbox\" class=\"make-switch\" data-on-color=\"primary\" " + (model.DefaultValue == "1" ? "checked" : "") + " data-off-color=\"default\" data-on-text=\"&nbsp;" + model.PlaceHoder + "&nbsp;\" data-off-text=\"&nbsp;" + model.PlaceHoder + "&nbsp;\" " + "  field=\"" + model.FieldName + "\"  " + "  field_type=\"" + model.FieldType + "\" >");
            Html_Str.Append("         <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");
            return Html_Str.ToString();
        }

        /// <summary>
        /// 编辑器2 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string FEditor(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();
            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-9\">");
            Html_Str.Append("        <textarea  id=\"feditor_default_" + model.FieldName + "\" style=\"display:none;\">" + model.DefaultValue + "</textarea>");
            Html_Str.Append("        <div id=\"feditor_" + model.FieldName + "\"  field=\"" + model.FieldName + "\"  field_type=\"" + model.FieldType + "\" style=\"width:100%;\"></div>");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");

            return Html_Str.ToString();
        }

        /// <summary>
        /// 字段列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static string FieldList(Model.SysModel.HtmlHelperModel model)
        {
            Html_Str.Clear();

            Html_Str.Append("<div class=\"form-group " + (model.Hide ? "hide" : "") + " \" " + (string.IsNullOrEmpty(model.Id) ? "" : "id=\"" + model.Id + "\"") + " >");
            Html_Str.Append("    <label class=\"control-label col-md-2\">" + model.Title + requiredFlag(model.FieldVerify) + "</label>");
            Html_Str.Append("    <div class=\"col-md-9\">");
            Html_Str.Append("        <div class=\"table-list\">");
            Html_Str.Append("            <table field_type =\"" + model.FieldType + "\" field=\"" + model.FieldName + "\"  id=\"Field_" + model.FieldName + "\" lay-filter=\"Field_" + model.FieldName + "\" ></table>");
            Html_Str.Append("            <div id = \"data_" + model.FieldName + "\"  class=\"hide\" >");
            //Html_Str.Append("                [{\"title\":\"我是标题1\",\"desc\":\"我是简介1\",\"img\":\"/uploads/20200109013936_054257.jpg\",\"file\":\"/uploads/20200228055920_387278.jpg\"},{\"title\":\"我是标题2\",\"desc\":\"我是简介2\",\"img\":\"/uploads/20200109013936_054257.jpg\",\"file\":\"/uploads/20200228055920_387278.jpg\"},{\"title\":\"我是标题3\",\"desc\":\"我是简介3\",\"img\":\"/uploads/20200109013936_054257.jpg\",\"file\":\"/uploads/20200228055920_387278.jpg\"},{\"title\":\"我是标题4\",\"desc\":\"我是简介4\",\"img\":\"/uploads/20200109013936_054257.jpg\",\"file\":\"/uploads/20200228055920_387278.jpg\"}]");
            Html_Str.Append("                " + model.DefaultValue);
            Html_Str.Append("            </div>");
            Html_Str.Append("            <div id = \"field_" + model.FieldName + "\"  class=\"hide\" >");
            //Html_Str.Append("                [{\"Field\":\"title\",\"Head\":\"标题\",\"Type\":\"input\",\"Tip\":\"这是字段提示\",\"Default\":\"\"},{\"Field\":\"desc\",\"Head\":\"简介\",\"Type\":\"textarea\",\"Tip\":\"这是字段提示\",\"Default\":\"\"},{\"Field\":\"img\",\"Head\":\"图片\",\"Type\":\"imgupload\",\"Tip\":\"1366*768\",\"Default\":\"\"},{\"Field\":\"file\",\"Head\":\"附件\",\"Type\":\"fileupload\",\"Tip\":\"这是字段提示\",\"Default\":\"\"}]");
            Html_Str.Append("                " + model.SelectItem["field"]);
            Html_Str.Append("            </div>");
            Html_Str.Append("        </div>");
            Html_Str.Append("        <span class=\"help-block\">" + model.Notice + "</span>");
            Html_Str.Append("    </div>");
            Html_Str.Append("</div>");

            return Html_Str.ToString();
        }


    }
}
